package com.ilovepostcard.model;

import org.json.JSONException;
import org.json.JSONObject;

public class Address {
	
    public long FAID;  //收件地址ID
    public long UserID;    //用户ID
    public String Name;    //姓名
    public String Telephone;    //电话
    public String Province;    //省份
    public String City;      //城市
    public String Address;      //详细地址
    public String Zipcode;        //邮政编码
    public String CreatedTime;     //地址创建时间

	public void setData(JSONObject json) throws JSONException {
	    FAID = json.getLong("FAID");
	    UserID = json.getLong("UserID");
	    Name = json.getString("Name");
	    Telephone = json.getString("Telephone");
	    Province = json.getString("Province");
	    City = json.getString("City");
	    Address = json.getString("Address");
	    Zipcode = json.getString("Zipcode");
	    CreatedTime = json.getString("CreatedTime");
	}
	
	public Address()
	{
		
	}
	
	public Address(String name,String phone,String zipCode,String address,String city,String Province)
	{
		this.Name = name;
		this.Telephone = phone;
		this.Zipcode = zipCode;
		this.Address = address;
		this.City = city;
		this.Province = Province;
	}
	
	public void setName(String name)
	{
		this.Name = name;
	}
	
	public String getName()
	{
		return Name;
	}
	
	public void setPhone(String phone)
	{
		this.Telephone = phone;
	}
	
	public String getPhone()
	{
		return Telephone;
	}
	
	public void setZipCode(String zipCode)
	{
		this.Zipcode = zipCode;
	}
	
	public String getZipCode()
	{
		return Zipcode;
	}
	
	
	public void setAddress(String address)
	{
		this.Address = address;
	}
	
	public String getAddress()
	{

		return Address;
	}
	
	public boolean equals(Object o)
	{
		
		if(o == null || !(o instanceof Address))
			return false;
		
		Address target = (Address)o;
		
		if(!compare(Name,target.getName())) return false;
		if(!compare(Telephone,target.getPhone())) return false;
		if(!compare(Zipcode,target.getZipCode())) return false;
		if(!compare(Address,target.getAddress())) return false;
		
		return true;
	}
	
	private boolean compare(String source, String target)
	{
		if(source == null ||target == null)
			return false;
		
		return source.equals(target);
	}
	

}
